#include "head.h"

int main(int argc, char const *argv[])
{
    if (argc < 2)
    {
        printf("格式错误 : %s file_src\n", argv[0]);
        return 0;
    }
    
        for (size_t i = 1; i < argc; i++)
        {
        FILE *fp_src = fopen(argv[i], "r+");
        FOPEN_ERR(fp_src);
        fseek(fp_src, 0, 0);
        

        FILE *fp_dest = fopen(argv[1], "a+");

        FOPEN_ERR(fp_dest);
  

        char buf[1024];

        memset(buf, 0, sizeof(buf));
        int byte = 0;
        while ((byte = fread(buf, 1, sizeof(buf), fp_src)) > 0)
        {
            fwrite(buf, 1, byte, fp_dest);
        }
        FILE *fp = fopen(argv[i], "w+");
        fclose(fp_dest);
        fclose(fp_src);
        fclose(fp);

    }

    return 0;
}
